package org.budo.support.javax.servlet.filter.request.read.repeatable;

import java.io.IOException;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;

import lombok.extern.slf4j.Slf4j;

/**
 * @author lmw
 */
@Slf4j
public class RepeatableReadRequestFilter implements Filter {
    public void init(FilterConfig filterConfig) throws ServletException {
        log.info("#25 RepeatableReadFilter init, this = " + this + ", filterConfig=" + filterConfig);
    }

    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
        RepeatableReadRequestWrapper requestWrapper = new RepeatableReadRequestWrapper(request);
        chain.doFilter(requestWrapper, response);
    }

    public void destroy() {
        log.info("#39 RepeatableReadFilter destroy, this = " + this);
    }
}